<?php
namespace Admin\Controller;

use Think\Controller;

class ScoreIntroductionController extends Controller
{
	
        
        

	
 
   //注意:在PHP.ini里面把;extension=php_zip.dll前面的分号去掉
         
        

    
    
    
public function ScoreImportExcel(){  

 header("Content-type: text/html; charset=utf-8");
        $Hint = new \Operation\Controller\HintController (); // 实例化Hint
        $Hint->checkLogin ( 3 ); // 验证是否登陆

      $upload = new \Think\Upload();
      $upload->maxSize   =     3145728 ;    
      $upload->exts      =     array('xls', 'csv', 'xlsx');  
      $upload->rootPath  =      './Public';    
      $upload->savePath  =      '/excel/';    
      $info   =   $upload->upload();
      if(!$info){
        $this->error($upload->getError());
      }else{
        $filename='./Public/'.$info['excel']['savepath'].$info['excel']['savename'];
        import("Org.Yufan.ExcelReader");
        $ExcelReader=new \ExcelReader();
        $arr=$ExcelReader->reader_excel($filename);
        $projectscore= M('projectscore');

        foreach ($arr as $key => $value)
       
       
        {
          
          $data['pid']=$arr[$key]['2'];
          $data['uid']=$arr[$key]['3'];
          $data['score']=strtotime($arr[$key]['4']); 

          M('projectscore')->add($data);        
        }



        if($data){
        $this->success('导入成功');}


        else{


          $this->error('导入失败');
        }
      }
    }
  }

                

  
 





